package com.tledu.spring.core.tools;

import com.tledu.spring.core.constants.CommonConstants;
import com.tledu.spring.domain.Cus;
import com.tledu.spring.domain.Role;
import com.tledu.spring.service.impl.RoleServiceImpl;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
import java.util.Arrays;
import java.util.List;

/**
 * @author Lsj
 * @version 1.0
 * @date 2021/7/7 14:41
 */
@Component
@AllArgsConstructor
public class JudgmentAuthority {

    private RoleServiceImpl roleService;

    public  List JudgmentAuthorityX(HttpServletRequest request){
        Cus cus = (Cus) request.getSession().getAttribute(CommonConstants.LOGIN_USER_SESSION_KEY);
        // 查询出role,之后是要看role中的权限
        Role role1 = roleService.selectAllByR_name(cus.getC_role());
        String r_x = role1.getR_auto();
        String[] tag = r_x.split(",");
        List<String> list = Arrays.asList(tag);
        return list;
    }
}
